package com.example.administrator.rxjavadiydemo.util;

import android.app.Activity;
import android.app.Dialog;

import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.example.administrator.rxjavadiydemo.R;
import com.example.administrator.rxjavadiydemo.view_activity.MainActivity;
import com.example.library.utils.ScreenUtils;
import com.example.library.utils.glideutils.imageutils.ImageUtilsManager;


/**
 * Created by lw on 2017/10/20 0020.
 */

public  class FragmentDialog extends DialogFragment {
    private MainActivity inter;

    public interface ILiveVideo{
        void displayAnimation(int pos);
    }
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        Dialog dialog = new Dialog(getActivity(), R.style.dialog_no_background);
//        dialog.getWindow().setBackgroundDrawable(new
//                ColorDrawable(Color.TRANSPARENT));
        dialog.setContentView(R.layout.fragment_dialog);
        dialog.setCanceledOnTouchOutside(false);
        dialog.setCancelable(false);
        Window window = dialog.getWindow();

        WindowManager.LayoutParams params = window.getAttributes();


//        int screenHeight = ScreenUtils.getScreenHeight(getActivity());
//        int screenWidth = ScreenUtils.getScreenWidth(getActivity());



        params.width = 100;
        params.height = 100;
        window.setGravity(Gravity.CENTER);
        window.setAttributes(params);
        initView(dialog);
        return dialog;
    }

    private void initView(final Dialog dialog) {
        ImageView imageView = (ImageView) dialog.findViewById(R.id.fragment_dialog_iv);
        AnimationDrawable spinner = (AnimationDrawable) imageView.getBackground();
        spinner.start();

    }
    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        if(activity instanceof MainActivity){
            inter = (MainActivity) activity;
        }


    }

    @Override
    public void onDetach() {
        super.onDetach();
    }
}
